home *** CD-ROM | disk | FTP | other *** search
- ±12 Inconvex Vector Objects
- ±13-------------------------------------
- ±12by Aragorn/Avalon
-
- ±11After a while you probably get bored
- just working with plain convex vector
- routines, because of the few
- opportunities they give you to design
- objects. So what you have to do then
- is to fix your routine a little bit
- so that it's able to handle inconvex
- objects. And that should open a new
- horizon for you and let you create
- much more interesting objects.
-
- First of all you need a normal hidden
- line vector routine to start out
- with. And as you know, in a convex
- routine you draw the lines directly
- in the screenbuffer, and that works
- fine since there is no intreference
- with more than one surface over the
- same area. However, when you are
- working with inconvex objects, this
- overlapping will occur. What you
- have to do then is to draw all the
- lines for one surface in a separate
- buffer, then fill the buffer, and
- blit it out on the screen. Then you
- clear the buffer, and do it over
- again until you have taken care of
- all the surfaces. Now, that is just
- a really simple way of saying it, so
- let's get a little deeper into what
- needs to be done...
-
- In addition to your screenbuffers you
- will need another buffer big enough
- for one bitplane in screen size
- (usually [256*40]=10240 bytes). This
- is where you'll draw and fill all
- your surfaces separately before
- blitting them onto the screen where
- the complete object will be created
- and shown. Since the surface buffer
- (the one explained above) is only in
- one bitplane, you'll have to label
- every surface in the declarations
- with the bitplanes you want it to be
- shown in. Here is an example on such
- a declaration:
-
- ±12dc.w %10,0,1,1,2,2,3,3,0,-1
-
- ±11Here, the first word shows which
- bitplanes the surface will be shown
- in. Then comes the coordinates the
- surface is drawn between (from,to,
- from,to...) and the last word marks
- end of surface. Then, after filling
- the surface it's time to blit it.
- Let's say you have the first word
- "%10" in d0. You simply test the
- bits in d0 to find where to blit the
- surface. And remember to clear the
- area which the surface covers in the
- bitplanes where it is not blitted
- out! Let's look at an example:
-
- ±13btst #0,d0 ; Draw Bpl1? [No]
- beq .No1 ; If No, Skip It!
- (BLIT SURFACE IN 1. BITPLANE)
- btst #1,d0 ; Draw Bpl2?
- bne .No1 ; If No, Clear It!
- (CLEAR SURFACE'S AREA IN 2. BITPLANE)
- .No1:
- btst #1,d0 ; Draw Bpl2? [Yes]
- beq .No2 ; If No, Skip It!
- (BLIT SURFACE IN 2. BITPLANE)
- btst #0,d0 ; Draw Bpl1? [No]
- bne .No2 ; If No, Clear It!
- (CLEAR SURFACE'S AREA IN 1. BITPLANE)
- .No2:
-
- ±11The answers in the brackets will go
- for the "%10" combination. Now all
- you need to do is to clear the
- surface-buffer and repeat the cycle
- until all the surfaces have been
- processed. And then your object is
- complete!
-
- "Now wait a minute", you might say;
- "how can I make sure that the
- surfaces are blitted out in the right
- order?". Well, since there is no
- routine that sorts the surfaces as
- they rotate and gets them in the
- right order, we'll have to pre-
- arrange the surfaces. That is done
- down in the declarations. The
- easiest way of explaining how to do
- that is just to switch around the
- orders the surfaces are declared in
- until it works. But here are some
- guidelines that you might find handy:
-
- ±13*±11 Declare the surfaces that are over,
- in front of, or outside the others
- at the end.
- ±13*±11 Declare the surfaces that are shown
- in all bitplanes last, or first.
-
-
- ±12Well, that is all I have to say about
- inconvex vector objects in this
- article. Good luck with your
- experiments!
-
- ±13 Aragorn/Avalon...ç